package userConsole.servlet;

import org.json.JSONException;
import userConsole.service.DeleteByIdService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author weishen
 */
@WebServlet("/deleteBatchServlet")
public class DeleteBatchServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String items = req.getParameter("delitems");
        System.out.println(items);
        String []strs = items.split(",");
        for(int i = 0 ;i < strs.length;i++)
        {
            try {
                new DeleteByIdService().deleteById(strs[i]);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
